<template>
	<view class="content">
		<template v-if="state">
			<image :src="baseUrl+'img/my/success.png'" class="icon"></image>
			<text class="result">预约成功</text>
			<text class="tips">您已预约成功，请注意服务时间！</text>
			<view class="sure" @click="$switchTab('/pages/service/service')">
				确定
			</view>
			<view class="message" @click="subscribeMessage">
				获取通知
			</view>
			<view class="back" @click="$navto.navto('/pages/myorder_index/myorder_index',{current:0,type:1})">
				查看订单
			</view>
		</template>
		<template v-else>
			<image :src="baseUrl+'img/my/fail.png'" class="icon"></image>
			<text class="result">预约失败</text>
			<text class="tips">别灰心，再次预约试试！</text>
			<view class="sure">
				再次预约
			</view>
			<view class="back">
				返回
			</view>
		</template>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				state: true,
				baseUrl: this.$baseUrl,
			}
		},
		methods: {
			subscribeMessage() {
				const tmplIds = ['Dl3WqJQXDvhmf5JElttpj7Z8XZ4kIV8neFt_6y3hbMo'];
				uni.requestSubscribeMessage({
					tmplIds: tmplIds,
					success: (res) => {
						if (res[tmplIds[0]] === 'accept') {
							this.$toast('订阅成功')
						} else {
							this.$toast('订阅失败')
						}
					},
					fail: (err) => {
						console.error('订阅失败', err);
						this.$toast('订阅失败')
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.back {
		width: 250rpx;
		height: 80rpx;
		border-radius: 6rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-weight: 500;
		font-size: 24rpx;
		color: #010101;
		letter-spacing: 5rpx;
		margin-top: 25rpx;
		border: 1rpx solid #010101;
		box-sizing: border-box;
	}
	.message {
		width: 250rpx;
		height: 80rpx;
		border-radius: 6rpx;
		background: #121212;
		display: flex;
		justify-content: center;
		align-items: center;
		font-weight: 500;
		font-size: 24rpx;
		color: #FFFFFF;
		letter-spacing: 5rpx;
		margin-top: 25rpx;
	}
	.sure {
		width: 250rpx;
		height: 80rpx;
		border-radius: 6rpx;
		background: #121212;
		display: flex;
		justify-content: center;
		align-items: center;
		font-weight: 500;
		font-size: 24rpx;
		color: #FFFFFF;
		letter-spacing: 5rpx;
		margin-top: 90rpx;
	}

	.tips {
		font-weight: 500;
		font-size: 24rpx;
		color: #8E8E8E;
		margin-top: 33rpx;
	}

	.result {
		font-weight: 700;
		font-size: 32rpx;
		color: #121212;
		letter-spacing: 6rpx;
		margin-top: 50rpx;
	}

	.icon {
		width: 220rpx;
		height: 220rpx;
		margin-top: 190rpx;
	}

	.content {
		width: 100%;
		height: 100vh;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
</style>